{% extends "base.html" %}

{% block title %}
medianBlur
{% endblock %}

{% block description %}
<p>Blurs an image using the median filter.</p>
{% endblock %}

{% block signature %}
<pre>cv2.medianBlur(src, ksize[, dst]) &rarr; dst</pre>
{% endblock %}

{% block parameters %}
<ul>
    <li><prmtr>src</prmtr> (<ptype>np.ndarray</ptype>): Input 1-, 3-, or 4-channel image; when <code>ksize</code> is 3 or 5, the image depth should be <code>cv2.CV_8U</code>, <code>cv2.CV_16U</code>, or <code>cv2.CV_32F</code>, for larger aperture sizes, it can only be <code>cv2.CV_8U</code>.</li>
    <li><prmtr>ksize</prmtr> (<ptype>int</ptype>): Aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7, etc. The <code>ksize</code> indicates the size of the square kernel to be used by this filter, i.e. how large of a neighborhood to use surrounding each pixel.</li>
    <li><prmtr>dst</prmtr> (optional; <ptype>np.ndarray</ptype>): Destination array of the same size and type as <code>src</code>.</li>
</ul>
{% endblock %}

{% block explanation %}
<p>
    The function smoothes an image using the median filter with the <code>ksize x ksize</code> aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported.
</p>
{% endblock %}

{% block notes %}
<ul>
    <li>The median filter runs through each element of the signal (in this case the image) and replaces each pixel with the median of its neighboring pixels (located in a square neighborhood around the evaluated pixel).</li>
    <li>In median blurring, the central element is always replaced by some pixel value in the image.</li>
    <li>This is highly effective against salt-and-pepper noise in an image.</li>
    <li>The median filter uses BORDER_REPLICATE internally to cope with border pixels.</li>
</ul>
{% endblock %}

{% block references %}
<ul>
    <li><a href="https://docs.opencv.org/master/d4/d86/group__imgproc__filter.html#ga564869aa33e58769b4469101aac458f9">OpenCV Documentation</a></li>
    <li><a href="https://docs.opencv.org/master/dc/dd3/tutorial_gausian_median_blur_bilateral_filter.html">OpenCV Tutorial: Smoothing Images</a></li>
</ul>
{% endblock %}
